<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		
	</head>
	
	<body>
		<h3>JavaScript访问DOM数案例</h3>
		<h5>JavaScript使用api的4种方式：访问h3标签，a标签，获取它们内容。</h5>

		<a href="http://www.taobao.com" target="_self">淘宝</a>
		<a class="jd" href="http://www.jd.com" target="_blank">京东</a>
		<a name="pdd" href="http://www.pinduoduo.com" target="_blank">拼多多</a>
		<a id="py" href="http://act.codeboy.com" target="_blank">java培优</a>;
		<script>
			console.log("输出");
			console.log(document.getElementsByTagName('a')[0].innerText);
			
			console.log(document.getElementsByClassName('jd')[0].innerText);
			console.log(document.getElementsByName("pdd")[0].innerText);
			console.log(document.getElementsByName('pdd')[0].href);
			console.log(document.getElementById('py').innerText);
			console.log(document.getElementById('py').href);
		
			var a=document.getElementsByTagName("a")[0];
			a.innerText="百度";
			a.href="http://www.baidu.com";
		</script>
		
	</body>
	
</html>
